package com.ftqh.project.travel.notes.entity;

import com.ftqh.project.travel.data.AbstractDomain;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Table;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2017/3/29
 * \* Time: 15:30
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
@Entity
@Table(name="travel_note_image")
@EntityListeners(AuditingEntityListener.class)
public class NoteImage extends AbstractDomain<Long> {
    private static final long serialVersionUID = 2343649103423691389L;

    private String name;
    private Long size;
    private String suffix;
    private String uri;

    private String authorName;
    private Long authorId;
    @Column(name="travel_note_id")
    private Long noteId;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getSize() {
        return size;
    }

    public void setSize(Long size) {
        this.size = size;
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public String getAuthorName() {
        return authorName;
    }

    public void setAuthorName(String authorName) {
        this.authorName = authorName;
    }

    public Long getAuthorId() {
        return authorId;
    }

    public void setAuthorId(Long authorId) {
        this.authorId = authorId;
    }

    public Long getNoteId() {
        return noteId;
    }

    public void setNoteId(Long noteId) {
        this.noteId = noteId;
    }

    @Override
    public String toString() {
        /*
        select id,
            username,
            email,
            phone,
            password,
            first_name,
            last_name,
            FROM_UNIXTIME(created_at/1000, '%Y-%m-%d %H:%i:%S') as created_at,
            FROM_UNIXTIME(last_modified/1000, '%Y-%m-%d %H:%i:%S') as last_modified
        from ftqh_online_store.sys_security_user;
         */
        return "NoteImage{" +
                "id='" + super.getId() + '\'' +
                "name='" + name + '\'' +
                ", size=" + size +
                ", suffix='" + suffix + '\'' +
                ", uri='" + uri + '\'' +
                ", authorName='" + authorName + '\'' +
                ", authorId=" + authorId +
                ", createdAt=" + getCreatedAt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) +
                ", noteId=" + noteId +
                '}';
    }
}
